<style>
    .layui-form .layui-form-item .layui-inline .layui-form-label {
        width: 100px;
    }
</style>
<form class="layui-form seller-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-3">
                <input type="text" name="username" placeholder="用户名称" autocomplete="off"
                       maxlength="50" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-3">
                <input type="text" name="reference" placeholder="订单号" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-3">
                <input type="text" name="transactionNo" placeholder="交易编号" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <select name="is_ok" >
                <option value="">请选择支付状态</option>
                <option value="0">等待中</option>
                <option value="1">已支付</option>
            </select>
        </div>
        <div class="layui-inline">
            <select name="pay_type" >
                <option value="">支付方式</option>
                <option value="0">支付宝</option>
                <option value="1">微信</option>
            </select>
        </div>
        <div class="layui-inline" style="padding-left: 5px;">
            <input type="text" name="datetime" id="datetime" placeholder="Start Time _ End Time" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="search"><i class="iconfont icon-chaxun"></i>Search</button>
            </div>
        </div>
    </div>
</form>

<div class="table-body">
    <table id="dataTable" lay-filter="dataTable" ></table>
</div>

<script>
    layui.use(['form',  'laydate' , 'table'], function () {
        var laydate = layui.laydate,
            form = layui.form,
            table = layui.table; //表格
        //时间插件
        laydate.render({
            elem: '#datetime',
            range: '_',
            format: 'yyyy-MM-dd'
        });
        var tableIn = layui.table.render({
            elem: '#dataTable',
            height: 'full-99',
            cellMinWidth: '80',
            totalRow: true,
            url: "{:url('pockyt')}",
            method:'POST',
            cols: [[
                { type: 'numbers'},
                { field: 'id', align: 'left',  title: 'ID', width: 60},
                { field: 'username', align: 'left',  title: '用户', width: 200},
                { field: 'transactionNo', align: 'left',  title: '交易编号',width: 240},
                { field: 'reference', align: 'left',  title: '订单号',width: 240},
                { field: 'amount',  align: 'right', title: '金额($)',width: 90,
                    style:'color:#FF5722;font-weight:bold',totalRow: true},
                { field: 'real_amount',  align: 'right', title: '实际付款($)',width: 120,
                    style:'color:#FF5722;font-weight:bold',totalRow: true},
                { align: 'left', title: '支付状态',width:90,
                    templet: function (d) {
                        const is_ok=d.is_ok;
                        var   color = "#6c757d";
                        var   show_name = '等待中';
                        if(is_ok == 1){
                            color = 'green';
                            show_name = '已支付';
                        }
                        return '<span style="color: ' + color + '">' + show_name + '</span>';
                    }
                },
                { align: 'left', title: '支付方式',width:110,
                    templet: function (d) {
                        const pay_type=d.pay_type;
                        var   color_1 = "#6c757d";
                        var   show_name_1 = '支付宝';
                        if(pay_type == 1){
                            color_1 = 'green';
                            show_name_1 = '微信';
                        }
                        return '<span style="color: ' + color_1 + '">' + show_name_1 + '</span>';
                    }
                },
                { field: 'ctime',align: 'center', title: '创建时间',width:180,
                    // templet: function (d) {
                    //     return d.ctime.substr(0,4) + '-' + d.ctime.substr(4,2) + '-' + d.ctime.substr(4,2)
                    // }
                },
                { field: 'utime',align: 'center', title: '结算时间',width:180,
                    // templet: function (d) {
                    //     const utime = d.utime;
                    //     if (utime == null) {
                    //         return ' -- ';
                    //     } else {
                    //         return layui.util.toDateString(utime * 1000, "yyyy-MM-dd HH:mm:ss");
                    //     }
                    // }
                }
            ]],
            page: true,
            limit: 50,
            limits: [50, 100, 500,1000],
        });
        layui.form.on('submit(search)', function (data) {
            layui.table.reload('dataTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                },
                method:'POST'
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        //余额编辑
        $(document).on('click', '.SearchDetail', function () {
            var id = $(this).attr('data-id');
            JsGet("{:url('server/showDetail')}?id="+ id, function(e){
                if(e.status == 1){
                    layer.open({
                        type: 1,
                        title: 'Log Detail',
                        area: ['1000px', '600px'], //宽高
                        content: e.datas,
                        btn:['Close']
                    });
                }else{
                    layer.msg(e.msg);
                }
            });
        });
    });
</script>